CentOS 7
Sponsored Link

Docker : Access to the Container
2015/01/10
 
If you'd like to access to services like HTTP or SSH which is running in Containers as a daemon, set like follows.
[1] For exmaple, use a Container which has httpd.
# start the Container and connect to the shell session

# map the port of Host and the port of Container with "-p xxx:xxx"

[root@dlp ~]#
docker run -it -p 8081:80 my_image/centos_httpd /bin/bash
# start httpd and exit the Container

[root@821bc61cb2e6 /]#
/usr/sbin/httpd &

[root@821bc61cb2e6 /]#
echo "httpd on Docker Container" > /var/www/html/index.html

[root@821bc61cb2e6 /]#
# exit with Ctrl+p, Ctrl+q
[root@dlp ~]#
docker ps

CONTAINER ID  IMAGE                        COMMAND      CREATED        STATUS        PORTS                  
821bc61cb2e6  my_image/centos_httpd:latest "/bin/bash"  54 seconds ago Up 53 seconds 0.0.0.0:8081->80/tcp
[2] Access to the URL via HTTP from a client which is in the same LAN with Container and make sure it's possible to access normally.
 
Tweet